1

My client needs to generate maps from shapefiles. Through my initial search, I came to know that we need to convert shapefiles to .kml then we can generate maps from google maps. So I searched for a script but could not find anywhere regarding that. So please help me with this problem. I am new to this, tell me am I going in right way?

One more thing, can we generate shapefile lines on a jpg image on the right place if I take an image of a state?

  • How often will you need to convert the SHP to KML? If it's a one-off conversion you could install the free QGIS application and do the conversion there. – Stephen Lead Aug 25 '14 at 5:54
  • i think its not possible in the webserver – nickle Aug 25 '14 at 6:25
  • Why does that matter? Are you trying to create a 'live' service whereby a shapefile can be uploaded to your server by a user and converted to KML on the fly? – MappaGnosis Aug 26 '14 at 14:57
1

It depends on how many files you need to convert. If you have a lot, a simple solution is to install the free GeoServer and publish all the shapefiles as WMS or WFS (depending on use-case). Geoserver handles the delivery and you do not need to no any conversion. This will allow you to overlay them in most web map scenarios without overloading your client with scripts to do the conversion.

Alternatively, you could create a batch process using OGR2OGR to convert to KML prior to use in the web map. But it looks like you have rejected a similar approach using QGIS. Though why you must have the conversion to KML in the webserver is not clear, but that solution is covered by using Geoserver.

Finally, see this solution which provides a JavaScript solution to convert the Shapefile to WKT which can then be consumed by most webmapping solutions.

  • can we able to run this ogr2ogr in web hosting server – nickle Aug 26 '14 at 9:54
  • You can probably call ogr2ogr as a subprocess through a serverside script if that is what you mean. Howevre, once you have converted your shapefiles to KML, there is nothing else to do. So, you need to be more specific by what you mean 'run in the web server' and why a batch process is not adequate for your use-case. Please edit your question with additional information. – MappaGnosis Aug 26 '14 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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