SHP to XLSX – Convert Shapefile to Excel



shp to xlsx

Sometimes we just need to see attribute details not geometry. So instead of carrying heavy shape files we can convert them in XLSX format. XLSX file contains on attribute detail or can say non spatial data. XLSX files are light in weight. Along with shp to xlsx convert you may also check for shp to ods, shp to csv conversion which also more focuses on attribute details.

Convert SHP to XLSX using MapOG Tool for hassle free conversion

KNOW ABOUT XLSX AND SHAPEFILE format -BEFORE CONVERTING SHP TO XLSX

An XLSX file is an Excel spreadsheet created by Microsoft Excel or another spreadsheet program. It stores data in worksheets, which contain cells arranged in a grid of rows and columns, and may also contain charts, mathematical functions, styles, and formatting. XLSX files create simple or complex mathematical models.

What is shapefile? Each object within a SHP file contains an individual geographic feature and its attributes.

Conversion from shapefile to XLSX using ogr2ogr utility-

–> ogr2ogr -f XLSX output_xlsx_filename.xlsx India_raods.shp

In command -f is file format and XLSX is driver. Then you can specify the output file name with .xlsx extension and input shapefile. This command can be executed on terminal or using PHP code. Here you must look for the ogr2ogr utility in your system. If not available you can install it using given line of code.

SHP to XLSX

Then you can check the presence of utility by typing ogr2ogr in terminal. The output will look like-

SHP to XLSX
SHP to XLSX

Note that while converting shapefile to XLSX, you must check for .shx file. If shx file is not available you may get following error.

SHP to XLSX

Shapefile has some supporting file like .dbf, .shx, .prj etc. So you must take all file whenever you perform conversion.

PHP CODE – SHP to XLSX

If you are aware of Shapefile Open description format, then you can easily access shapefile data through coding. As i have created one such shapefile minimum bounding box parser in c++. Below in the php code to execute ogr2ogr tool.

Here you can perform the conversion using shell_exec() method, which actually executes the command and returns string as output.

public function shptoxlsx($shpfilepath,$output) {
$query=”ogr2ogr -f XLSX $output.xlsx $shpfilepath.shp”;
shell_exec($query);
}

After execution of command you can check the specified folder to see generated xlsx file. The content of file will be something like-

SHP to XLSX

You may also look forward to convert shapefile to GeoJSON, Shapefile to Kml, Shapefile to topojson and etc conversions.

Hope you enjoyed the article and successfully converted shape file into XLSX file. If you have any problem regarding conversion please feel free to write in comment box.

Author: Akshay Upadhyay

Owner and Director of a Private Limited company which serves individual to large scale industries in the field of Maps and GIS. He is a Gold Medalist in M.Tech(Spatial Information Technology) and owns some famous Technology blogs and website... Know more

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.