Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

NOTE: this question is sorta like a follow-on question to this original GIS Question I asked. In that question, the main suggestion was that I was trying to show two polys. Now, I'm asking about a SINGLE poly.

I have the following GEOGRPAHY of Los Angeles in my Sql Server 2008 :-

enter image description here

Sql script to repo it (or in RAW sql format)

It's bascially ..

-- Shape of Los Angeles.

DECLARE @WKT VARCHAR(MAX) = 'POLYGON ((-118.66815700000011 34.181235000000029, ... ))

Now when I just try and render this out, It now looks like this (NOTE: this is different, but still not correct .. compared to my previous GIS Question).

enter image description here

Now, in the previous question people were suggesting that the previous data was a MULTIPOLYGON so there was some bad stuff I must have been doing, trying to render out holes in polys.

This time, this is a single polygon. So i'm assuming the hole theory still doesn't work. Now, I understand that by looking at this image, there's a number of holes ... but the Well Known Text data which Sql Server gives me is a POLYGON which to me means .. one single shape. So i'm not sure how I can fix this :(

This is why i'm asking the a similar question to my previous one.

Can anyone help? Can they see the data I've posted and see what happens in other systems? (I don't have any other software besides Sql Server 2008).

Maybe I need to extract all my data from Sql Server 2008 .. and clean it up (whatever that means) through another system. For example. If Sql Server is saying that the shape of Los Angeles is a single Polygon .. but when cleaned up .. it's actually 7 Polygons .. and then those shapes then get rendered correctly .. then we have a solution!

Any suggestions?

Can -anyone- render this shape onto a Google map?

share|improve this question
I think your polygon is fine- I was able to take your raw data, replace some parens with brackets and spaces with commas and display it on an Esri JS API map: Any chance this would get you to migrate to the Esri API (full disclosure: I work for Esri on the JS API team)? I didn't need to modify any the ring ordering or "winding" as people said in your other question. – Derek Swingley Dec 13 '11 at 4:27
Mike, it is still a multipolygon, but one with internal polygons; it is still being rendered as a multipolygon. One polygon, would be simply that, one polygon, with no holes, islands or donuts. This is many polygons. – Hairy Dec 13 '11 at 10:37
@Hairy That doesn't matter. If your polygon has 1 ring or 1000, keep adding them to your geometry. Both the Esri and Google APIs handle the geometry correctly. Please see my answer for examples. – Derek Swingley Dec 13 '11 at 15:43
The ESRI doesn't afaik, it differentiates the interior polygons as anticlockwise. Not too sure on Google. – Hairy Dec 14 '11 at 7:24
BTW, very good answer from you. It may also be that I am thinking of the wrong api in ESRI – Hairy Dec 14 '11 at 7:25
up vote 9 down vote accepted

I was able to get this to work:

Here's a screenshot: enter image description here

As I said in my comment, I reformatted your raw data. I did this with some python and a little hand-jamming. The resulting JSON is here: That's the Esri JSON format for a polygon. The link above converts the geometry from the Esri JSON format to the Google format, which is a two dimensional array.

It seems like there's a problem converting the response from SQL Server to the two dimensional array that Google expects. I would look at your code doing that conversion.

share|improve this answer
So you had to do this manually? look at the raw data and then move things around? (eeks). Is it worth my putting up my code that shows how I convert some Sql WKT into Google polygons? .NET -> Json -> Javascript. – Pure.Krome Dec 13 '11 at 5:29
It took me about 20 minutes to write up some python to reformat and then display your data on an Esri map. From there, it only took a couple minutes to get it on Google. I was curious to see if the data would display with minimal work. That is, would it work with some basic reformatting/syntax changes and without significant changes to the geometry. You can post your code to convert from WKT --> JSON but I'm not sure how much I'll be able to help since I don't do a whole lot with .NET. – Derek Swingley Dec 13 '11 at 15:40

I know this has already been answered, but an easier solution I found was to actually use the javascript toolkit called OpenLayers and export the shape from Sql Server as Well Known Text .. and then use OpenLayers to display that WKT data.

this implied that my javascript code using the Google Maps API was bad and/or my code to export the json points was bad.

Anyways, using WKT works :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.