The GIS Forum
The GIS Forum is a community site for Spatial users to connect and grow

Plotting polygons on a map

rated by 0 users
Not Answered This post has 0 verified answers | 22 Replies | 2 Followers

Top 50 Contributor
11 Posts
1LostGuy posted on 07-13-2009 3:34 AM

Hi,

 

I have what I suspect is a very basic question about plotting polygons as an overlay on a map. But after countless hours reviewing help topics in Google Earth, ESRI, GIS, GPS Visualizer, and various forums, I am still unclear, confused, and seem to be missing what I assume are obvious answers/options.

 

The problem is this:  I want to find a way to plot a set of polygon data, stored in a .TXT file of CSV data in a format like this:

 

1; GeomFromText('POLYGON(39.711479, -104.94, 39.696324, -104.94, 39.696324,-104.90,39.711479, -104.90)')

 

as an overlay on a zoomable street map, whether in Google, ESRI, Thomas Brothers – I don’t care!

 

I know how to create (draw) and save polygons in Google Earth, but instead I want to import a file of polygon data that has already been created (in the format above).Do I have to purchase a more advanced form of Google Earth (EC or PRO)? Similarly, GPS Visualizer only allows me to import point data.

 

I am happy to eventually purchase a full-service retail utility, but I first want to see a demo, to get a feel for what is involved, as a sort of proof-of-concept.

 

It seems obvious to me that this must be a rather simple, well-known, “solved” problem, whether in Google Earth, or ESRI, or some other program/service, or alternatively, via one or more standalone utilities not tied to a particular map vendor. I am *not* trying to develop an app using an API, nor write original code to do this, nor even to import library code into some app.

I just want to see what all my polygons look like on an underlying map!

 

For any help, I will be eternally grateful (and so will the remaining hairs on my head).

 

Thanks!

 

– 1LostGuy

 

 

All Replies

Top 10 Contributor
178 Posts

I wonder if GPSBabel would be of any help? I don't think it will create polygons though...

Top 50 Contributor
11 Posts
Hi Dylan, Thanks for the reply -- and the tip! Unfortunately, you are correct that GPSBabel doesn't do polygons, as far as I can tell. But it's not *creating* (unless you mean plotting) polygons that is my problem. Rather, I already have a bunch of polygon data, and although various packages seem to claim they can be plotted, I can't seem to find the right format and/or proceudres to make any of them work. [sigh] Thank you again for taking the time to offer advice. -- Gary (1LostGuy)
Top 10 Contributor
178 Posts

Oh, okay, I see what you've got going on. I don't know why I thought you had GPS data...

I think what you need to look into is Well Known Text (WKT) format for a polygon. ogr2ogr should help you get to shapefiles or a format that will let you display them in ArcMap or QGIS, etc.

Or, if you're comfortable with SQL you should be able to use PostGIS's geometry from text function to create polygons on your own.

dylan

Top 50 Contributor
8 Posts

GPS Visualizer can plot non-point data, even polygons, as long as you let the computer know what you're trying to do.  Your "command" won't work right out of the box, but if you add some line breaks and column headings, you can easily plot a polygon in Google Earth using GPS Visualizer by sending this text:

type,lat,lon,name,color,fill_opacity
T,39.711479,-104.94,my polygon,red,0.5
T,39.696324,-104.94
T,39.696324,-104.90
T,39.711479,-104.90
T,39.711479,-104.94

The "type" column filled with T's tells GPS Visualizer that this is a track, not waypoints (using GPS terminology).  The presence of a fill_opacity in the first row of the track causes it to be drawn as a filled oplygon in Google Maps or Google Earth.  (The "name" is also defined in the first row.)  I repeated the first point at the end of the list to complete the quadrangle.

I'll admit to not knowing much about the "real" GIS world... if the GeomFromText command that you posted is a standard thing, let me know and I'll see about adding support for it to GPS Visualizer's code.  And please let me know if you have any other questions about GPS Visualizer.

 

Top 50 Contributor
11 Posts

Thanks, Dylan. I checked it out, and indeed, it appears that WKT would be the way to go for generic coding of the data, with maximum control (programmability).

Now I know.

Fortunately, Adam (see other post) enlightened me on how to, after all, quickly and easily generate the overlay I need from GPSVisualizer.

But I very much appreciate the info, and also everyone’s helpfulness. What a great forum!

Regards,

-- Gary

Top 50 Contributor
11 Posts

Hi Adam,

Or as my teenage daughter would say -- OMG! I got a detailed reply from the *creator* of GPSVisualizer!

Okay, I'm impressed. And yes, it works as claimed.

Customer suggestion: I may have missed something in the examples and various instructions, but it wasn’t clear to me that “tracks” can be used to construct polygons. When I think about it, it’s a “duh” moment, but as I have seen many mapping programs that refer to polygons explicitly, maybe it would help to mention this in the “documentation” somewhere. Of course, perhaps you already did, and I, in my increasing neuronal decrepitude, I skipped right over it. Anyway, it works great. And had I bothered to view the tutorials first, I no doubt would have quickly discovered how do to the “extended” column header list to incorporate all the parameters I needed.

Of course, while I can create a batch utility to recode my data into your format, I’ll have to do some additional work to duplicate the first point at the end of each cluster, to close the track, as you showed me. But that’s not a problem for now.

As for the data format that I listed, I don’t know if the GeomFromText is some kind of known standard, as I inherited the data files thrice removed from their origin. I'll check into it. But I do know, as you obviously do as well, that defining polygons directly (that is, as polygons, not via a closed track) is a standard representation in the geocoding mapping world. Indeed, Google Earth indicates support for this in the KML/KMZ format, a format which you support in your app. I haven’t been able to figure out how the polygons that I manually draw in GE are actually represented in a data format (as GE simply shows the icons in My Places), but I gather that I could see how it is coded by entering my data in the Convert page of GPSV, and then examining the resulting KML/Z file data.

Come to think of it: since GPSV supports the conversion to KML/Z, do you happen to know how KML/Z codes for polygons? Then, I could go that route (NPI), and simply convert some version of my data into that format (saving the need for adding the dupklicate intial points) via GPSV first, then importing the file into GE.

Meanwhile, I’ll explore your amazing software more, and thanks for the offer to answer further questions.

GPSV is a great “product”, and as I will probably be using it quite a bit to deliver proof-of-concept maps to my client, I will have him provide an appropriate donation to your effort.

To you and everyone on the GIS Forum, I am, as I said in my initial post, eternally grateful (just like our favorite LGM).

Regards,

– Gary (1LostGuy)

Top 50 Contributor
8 Posts

No, you didn't miss anything in the documentation.  In the "tracks" tutorial, there's a passing mention of fill opacity, but nowhere have I explicitly stated the essential point: If you supply a non-zero "fill opacity" in the first row of a track's data, it will be drawn as a polygon in Google Maps or Google Earth.  The whole fill_opacity thing was only originally included in GPS Visualizer because sometimes people upload KML files that include polygons, and I wanted to be able to replicate them in GM or GE.  Obviously, the tracks tutorial needs some help -- but manually-created polygons are a little-used feature anyway, so documenting them hasn't been a priority.

By the way, you don't NEED to duplicate the first point.  But if your polygon has an opaque border on it -- which it will by default -- it will be an "open" border if you don't bring the track back to the first point; I think that's pretty intuitive.  If you don't want to mess with closing the shape, and you don't need an outline on it, specify a "width" of 0.

If you want to see how KML does polygons, you don't need to run it through GPSV.  Just right-click on one of your hand-drawn polygons in Google Earth's sidebar, click "Save As," and save it as KML.  Then open it up in a text editor.  You'll see something like this in there:

      <Placemark>
        <Polygon>
          <altitudeMode>clampToGround</altitudeMode>
          <outerBoundaryIs>
            <LinearRing>
              <coordinates>-104.94,39.711479,0 -104.94,39.696324,0 -104.9,39.696324,0 -104.9,39.711479,0 -104.94,39.711479,0</coordinates>
            </LinearRing>
          </outerBoundaryIs>
          <tessellate>1</tessellate>
        </Polygon>
      </Placemark>

Top 50 Contributor
11 Posts

Thanks again, Adam. I think I'm off & running, now, on both GPSV, and KML.

-- G

Top 10 Contributor
178 Posts

Glad you got a good answer!

Thanks for the information too, Adam.

dylan

Top 50 Contributor
8 Posts

By the way, I did finally add a little "Creating polygons" section to the GPS Visualizer tracks tutorial.

Top 10 Contributor
Male
40 Posts

BTW, you already have WKT embedded there. Everything within the quotes in your GeomFromText function is WKT. SharpMap can visualize that pretty easily for you as well.

Top 50 Contributor
11 Posts

Good move.

Also, as you had asked about the format my data was in, and whether it was some sort of standard, Dylan had it right. The format is a MySQYL GIS dialect called PostGIS, where the argument text is indeed WKT. Bill D just noted this as well.

This will work well when I hand off the spec for back-end programming (which is no longer my forte), where I can store and maintain and update the data in a mySQL database, and, I gather, then use PostGIS to create the polygon functions, and then port them to ArcMap, SharpMap, or some other app to display.

But for now, I would like to simply store the data in a spreadsheet, which is easy to do if I batch-strip the coordinates as an octuplet, and insert them into a .csv Excel sheet row. Alas, if wish to then use GPSV, I have to reformat each spreadheet row of 8 coords into 5 rows (with the duplicate endpoint) of doublets. A real hassle. So, unless anyone has a non-labor-intensive way to do that, I'll probably have to bite the bullet and go directly to MySQL/PostGIS.

Thanks, as ever. . .

-- G

 

 

Top 50 Contributor
11 Posts

Thanks, BIll. You are correct. I was trying to avoid that route for the prototyping phase of my project. But I may have to go that way. See my latest note to Adam.

Regards,

-- Gary

Top 50 Contributor
8 Posts

I'm not going to attempt to learn how to parse all of the "WKT" commands, but I did at least add support for those POLYGONs.  Gary, if you paste your GeomFromText thing into GPS Visualizer, it will be understood and rendered as a polygon with 40% fill opacity.  That should make your task a bit easier.

Page 1 of 2 (23 items) 1 2 Next > | RSS
Bookmark and Share
Creative Commons License

PLEASE SEE THE THE LICENSE FROM THE ORIGINAL SOURCE FOR ALL POSTS PULLED INTO THE COMMUNITY MASHUP BLOG SECTION