How to Download Maps from GIS websites
January 27, 2023 Vaidya R
Many map sites as well as public utilities put out their maps for public consumption. This data is exposed in the form of Rest URLs and can be downloaded as map files with the right tools.
What you need
- Python needs to be installed on your machine. You can download python from here.
- After Python in installed check whether “pip” is installed. Most python installations come with pip installed. But you can check this way:
- Open commandline using “Windows + R” and typing “cmd”.
- Enter the command: python -m ensurepip
- If pip is installed it will give an output that says “Requirement already satisfied”.
- If pip is not installed, you can install it using the steps detailed here.
- Once you have python and pip, install the esridump package using the command:
“pip install esridump”. - Add the path to the command esri2geojson to the environment variables. If you don’t know how to do that, you can find the steps here for windows. For Mac, check here.
How to download map files
- Now that you have python as well esridump installed, you need the URL.
A REST Url will look like this: https://dev.ksrsac.in/maps/rest/services.
Opening the URL with a browser will give you a list of links which will look like this: - The above is a folder. Pick a link below and click on it. Keep navigating deeper until you hit a MapServer. A MapServer will have the list of the actual maps and will have the text “MapServer” in the URL as well as on the page.
- Now that you have the list of maps, you can download each one. For e.g. to download the map of Toilets above, you can use the URL of the page from the browser: https://dev.ksrsac.in/maps/rest/services/BBMP/BBMP/MapServer and the number of the map, which can be seen next to the name “Toilet”. In this case it is 7. If the number is not visible, click on Toilet and get the URL for the map.
The final URL will look like this:
https://dev.ksrsac.in/maps/rest/services/BBMP/BBMP/MapServer/7 - Open commandline using Windows + R and typing cmd in the case of Windows, or Terminal in the case of Mac/Linux. Make sure the path to Python is part of the environments variable PATH.
- Type the command:
esri2geojson <Your URL> <Output File.geojson>
In the above example that would be:
esri2geojson https://dev.ksrsac.in/maps/rest/services/BBMP/BBMP/MapServer/7 “BBMP toilets.geojson” - In the case of success the output will be:
023-01-27 10:51:50,757 – cli.esridump – INFO – Built 1 requests using resultOffset method
You can load and view the geojson on your preferred map viewing tool like QGIS or Google Earth.