Pontiacks
Pontiacks

Reputation: 1158

Display Shapefiles .shp areas and markers on Google Maps API?

I have some Shapefiles displaying areas and others displaying points on the map, I want to use those on my web application and use Google Maps API. How do I do that?

I've tried converting them to more managable .kml files, but I can't do it because there are no coordinates in the .dbf file (checked using Excel). I'm stuck now. Thanks.

Upvotes: 2

Views: 3475

Answers (1)

cengel
cengel

Reputation: 272

As geocodezip already suggests, for the bike_sharing_places you could use ogr2ogr like this:

ogr2ogr -f KML bike_sharing_places.kml BIKE_SH.shp -t_srs EPSG:4326 -s_srs EPSG:3003

This converts your shapefile to KML and reprojects from your projection (Monte_Mario_Italy_zone_1 EPSG:3003) to WGS84 (EPSG:4326), which is required for Google Maps.

In your other file (dogs_park) the file with projection information is missing. I took a guess, and it appears to be in UTM 32N (EPSG:32632). So you first have to assign that projection.

ogr2ogr -a_srs EPSG:32632 aree_fruizione_cani_UTM.shp aree_fruizione_cani.shp

Then convert and reproject:

ogr2ogr -f KML dogs_park.kml aree_fruizione_cani_UTM.shp -t_srs EPSG:4326 -s_srs EPSG:32632

Upvotes: 2

Related Questions