2

I have an Excel file that contains polygon coordinates for different areas. The spreadsheet has three columns: latitude, longitude and area name. Each coordinate makes of a part of the boundary of a polygonal area.

A sample of the data can be viewed here on google docs.

A subset of that sample is below:

Latitude   Longitude   AreaName
43.76559098    -79.41218646    Area1
43.76551428    -79.41216573    Area1
43.76516783    -79.41207212    Area1
43.76476698    -79.41196381    Area1
43.73581704    -79.4559399     Area2
43.73327829    -79.45336613    Area2
43.73359084    -79.45189026    Area2
43.73388256    -79.45052026    Area2

How can I turn this data into a shapefile that can be imported into CartoDB as a set of polygons?

Note: CartoDB accepts shapefiles that are in the following format.

zgall1
  • 113
  • 7
  • Turning it into a point shapefile is fairly simple, I'm not sure about polygon shapefile as I haven't tried doing that myself. You will need to separate the cordinates into 2 columns than add them in ArcMap using the Add XY data option. Take a look at this – Hasan Mustafa Mar 25 '16 at 04:53
  • @zgall1 what are these 'areas' you're referencing? Do they exist in a shapefile that you know of? You're only showing X,Y locations, not polygons, but you are calling them area1, area2, etc... where did those names come from? – DPSSpatial_BoycottingGISSE Mar 25 '16 at 19:28
  • @mapBaker An area is a school catchment area. Here is an example of one such catchment area - http://www.tdsb.on.ca/Findyour/School/ByMap.aspx?focusOnSchool=4312. If you view the source code for the page, you can find the coordinates that make up the entire polygon. I am not sure if a single shapefile exists that contains the entire set of catchment area bonundaries but even if it did, the organization that manages that site (the TDSB) would not release it publicly. – zgall1 Mar 25 '16 at 19:51
  • @zgall1 I think that explains your problem! We (Denver Public Schools) make our school district boundaries public - you should reach out to TDSB and see if they can do the same, because without those polygons, you're not going to have any luck... – DPSSpatial_BoycottingGISSE Mar 25 '16 at 19:53
  • @mapBaker I already know that the TDSB will not release shapefile for their catchment areas. My intent was to scrape the polygonal coordinates from the website I linked to. – zgall1 Mar 26 '16 at 04:58
  • @zgall1 glad we got that figured out. Now you can edit your question as such. – DPSSpatial_BoycottingGISSE Mar 26 '16 at 18:30
  • @mapBaker What part of the questions needs to be edited? – zgall1 Mar 26 '16 at 18:47
  • Well you're asking how to convert points to polygons, and giving 1 pair of XY coordinates and expecting CartoDB to create Toronto School District polygons from them. That in itself is not going to work. So I dug into what you are trying to do, and you said you're trying to scrape features from a web API into polygons - so if you edit your question to ask 'how to scrape polygons from a web mapping API', you'd be asking something closer to what you're trying to do (though I doubt you'll get a good answer...). I still say ask them for their data - WE PAY for that data with our taxes. – DPSSpatial_BoycottingGISSE Mar 26 '16 at 19:40
  • @mapBaker I don't want an answer to the question you are suggesting I ask. I know how to scrape the data. Also, I am not giving a pair of XY coordinates and asking for help on creating polygons. If you look at the sample data in the linked Google Sheets file, you will see the full set of coordinates for two complete polygons. I believe my question is an accurate reflection of the help I require. Whether anyone is able to help is an entirely different matter. – zgall1 Mar 26 '16 at 19:43
  • @zgall1 then you should scrape the data - otherwise you should load the data into cartodb and try to use the ST_ConvexHull function around the geometry column and group by Areaname – DPSSpatial_BoycottingGISSE Mar 26 '16 at 20:01
  • @mapBaker Once I have scraped the full dataset, I will be left with a set of polygonal coordinates that I know cannot be directly uploaded into CartoDB. I need to transform them into a .SHP file (ESRI created format for shapefiles) or one of the other supported file formats listed here - http://docs.cartodb.com/cartodb-editor/datasets/#supported-file-formats. The essence of my question is how to I take the polygonal coordinates and transform them into a supported file format. – zgall1 Mar 26 '16 at 20:05

1 Answers1

1

Your scraped data will look like this:

enter image description here

What you have to do, and what your question should ask, is how to take grouped points and convert them into polygons for each Area in your data

See an answer like this: Converting point sets to polygon boundaries? but I don't know if it will 'rebuild' the polygons that were used to create the sets of LAT/LON

DPSSpatial_BoycottingGISSE
  • 18,790
  • 4
  • 66
  • 110
  • Thank you for the explanation. It seems I have dramatically underestimated the complexity of what I am looking to do. Given the specific map, e.g., http://www.tdsb.on.ca/Findyour/School/ByMap.aspx?focusOnSchool=5306, is there any way to extract any additional information that would be beneficial in determining the exact shape of the polygon? – zgall1 Mar 26 '16 at 20:14
  • A follow up question - if I know that point A connects to point B connects to points C ... connects to point Z, does that in any way simplify the process of reconstructing the polygon from a set of points? – zgall1 Mar 26 '16 at 20:16
  • In CartoDB, I would expect ST_ConvexHull (geom) to work, but it doesn't - so my last recommendation would be how to convert points to polygons in CartoDB... otherwise, ST_ConvexHull should do this in PostGIS (what CartoDB is based on...) - lastly, there may be some bigger object behind the scenes of that website with the complete polygons - like a GeoJSON file, KML, or a web service... might want to check for a complete polygon file on their server... – DPSSpatial_BoycottingGISSE Mar 26 '16 at 20:31
  • I am far from an expert on this but I've done a bit more thinking about your answer and I'm not sure if this is as complex as you have made it out to be. The set of points for a given polygon creates a full polygon as the first and last coordinate for a given polygon are the same. Isn't there a tool or function that says connect point A to point B to point C to point D to point A? Something like this - https://developers.google.com/maps/documentation/javascript/examples/polygon-simple – zgall1 Mar 26 '16 at 20:37
  • Only one way to find out... – DPSSpatial_BoycottingGISSE Mar 26 '16 at 21:15
  • Are you suggesting I ask this as a separate question? I think that makes the most sense but I am not sure if I am interpreting your comment correctly. Thanks. – zgall1 Mar 29 '16 at 03:32
  • @zgall1 I'm suggesting you try to get the source data – DPSSpatial_BoycottingGISSE Mar 29 '16 at 12:39