I have shapefiles i.e. *.shp, *.dbf and *.shx files.

I need to read geo coordinates from these files and overlay the area on Google Maps at the right location.

I believe that *.shp and *.dbf files contain coordinates.

I have also used gotools api to read ArcGIS files and am able to generate map.

Is it possible to do this?

  • By "gotools api" do you mean GeoTools?
    – PolyGeo
    Aug 8, 2013 at 10:23

4 Answers 4


I suggest you taking a look at Reading ESRI Shapefiles with PHP.

It is a class written in PHP that can be used to read shapefiles. Once you manage to read a shapefile, you can easily extract its contents i.e. latitudes and longitudes. Here is a snippet from the webpage:

// including the shapefile reader class
    require 'ShapeFile.inc.php';

// importing the downloaded shapefile
    $shp = new ShapeFile("5961.shp", array('noparts' => false));

Once you got the coordinates from the shapefile on the server side, just put them into an array and use PHP's json_encode() command to create a JSON array from the PHP array, set the content type to application/json or text/json and echo the whole stuff. Then you can process this on the client side easily.


If you happen to use QGIS, I found this tutorial http://centigonknowledge.com/tutorial/extract_geometry/. It explains how to create the coordinates from a shapefile (containing points) and extract them to Excel so you can plug and play into Google Maps.

Here is a summary,

  1. Open your Shapefile in Quantum GIS (open source GIS tool)
  2. Go to toolbar Vector>geometry tools>Add Geometry Columns. 3.Go to the directory containing your shapefile and open the DBF file in Excel
  3. THe last two columns will contain the coordinates you were looking for so you can plug into Google Maps API.

Make sure you shapefile is projected correctly then you can use Google Engine to upload your shapefile, see this link Uploading Data to Google Maps Engine.


Open your .dbf in Excel and save it as a .csv

You can then add this .csv file to Google Maps and specify your X,Y columns with the 'Create Map' tool:

enter image description here

@johanvdw I thought the user stated he has the X,Ys already in the .dbf

@Devdatta Tengshe I assumed he is trying to view his shapefile in Google Maps, I've uploaded a screenshot - from here you can import your files into GM as I thought the user was requesting. Maybe I have misunderstood the question!?

  • This would only work if the dbf file contains X and Y columns. If this is not the case you could add them (if your file is a point shape file) using eg saga gis. This has a module "add coordinates to points".
    – johanvdw
    Nov 13, 2013 at 9:25
  • I don't see how you can convert the 'shape' part of the ShapeFile into CSV. It's not even clear what the 'Create Map' tool is. Nov 13, 2013 at 9:25
  • Edited. I would like to know if I have misinterpreted the question and thus keep/delete my answer accordingly.
    – Rob Lodge
    Nov 13, 2013 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.