Skip to content

stepanosokin/RfgfLicenseLoader

Repository files navigation

RfgfLicenseLoader

There is a wonderful site https://rfgf.ru/ReestrLic/ which contains information about all the license blocks in Russian Federation provided by Rosgeolfond. The good news is that you can download all the database from its webservice and use it offline in your GIS.

This is Python script to download data from https://rfgf.ru/ReestrLic/. This script contains the class RfgfLicenseDownloader to download, parse and save to Geopackage the License Blocks data from https://rfgf.ru/ReestrLic/ website. The class has 2 main methods:

  1. RfgfLicenseLoader.download(<<json_request>>, <<json_result>>) This is a function to download data about license blocks in json format from https://rfgf.ru/ReestrLic/ site :param json_request: This is the json request file. Instructions to get a sample of this file: 1. Use Chrome to open https://rfgf.ru/ReestrLic/ site; 2. Activate DevTools by pressing F12. Go to Network tab; 3. Make some request on the Rfgf catalog page with no filters; 4. in DevTools, select the last query object in Name pane. Then go to the Payload tab on the right. Click 'view source'. Then click 'Show more' at the bottom. You now see the complete search request to the webservice in json format. Just copy/paste this json text to any text editor; 5. Find the "limit":100 parameter and change it to some big value, e.g. 250000. Save the file. This is your json request file that you can use for this function. :param json_result: path to the result data json file

  2. RfgfLicenseLoader.json2gpkg(<<json_file>>, <<geopackage_file>>, <<layer_name>>) This function parses data from json_file generated by RfgfLicenseLoader.download() function and writes it to Geopackage. :param json_file: path to the json file with data about license blocks generated by RfgfLicenseLoader.download() function :param gpkg_file: path to geopackage with result layer. Geopackage must exist. Recommended: geopackage name must not exceed 3 letters :param layer_name: layer name inside geopackage to write the final result. The layer must have multipolygon geometry, WGS-1984 CRS and predefined field structure:

    field_name Type Length

    gos_reg_num String 0 date_register Date 0 license_purpose String 0 resource_type String 0 license_block_name String 0 region String 0 status String 0 user_info String 0 licensor String 0 license_doc_requisites String 0 license_cancel_order_info String 0 date_stop_subsoil_usage Date 0 limit_conditions_stop_subsoil_usage String 0 date_license_stop Date 0 previous_license_info String 0 asln_link String 0 source String 0 license_update_info String 0 license_re_registration_info String 0 rfgf_link String 0 comments String 0 source_gcs String 0 coords_text String 0

:return: prints message about every 1000 json rows parsed

What you need to do to use the script:

  1. any Python IDE (PyCharm, IntellijIdea, etc.)

  2. qgis and osgeo Python libraries in your Python environment. OSGeo4W software package is a good option. If have OSGeo4w installed and want to configure PyCharm to use with QGIS (PyQgis), you may use these instructions: https://haifengniu.com/post/how-to-set-environment-for-pyqgis-3-in-pycharm/

  3. Create new project. Add RfgfLicenseLoader.py file to the project. OR just clone the project from here using git.

  4. create an instance of RfgfLicenseLoader class: my_RfgfLoader = RfgfLicenseLoader()

  5. generate json request file from https://rfgf.ru/ReestrLic/ site or use attached rfgf_request_example_noFilter_250000.json to run the download method to download the license blocks database from https://rfgf.ru/ReestrLic/ in json format.

5.1. how to generate json request file from https://rfgf.ru/ReestrLic/ site: 5.1.1. Use Chrome to open https://rfgf.ru/ReestrLic/ site; 5.1.2. Activate DevTools by pressing F12. Go to Network tab; 5.1.3. Make some request on the Rfgf catalog page with no filters; 5.1.4. in DevTools, select the last query object in Name pane. Then go to the Payload tab on the right. Click 'view source'. Then click 'Show more' at the bottom. You now see the complete search request to the webservice in json format. Just copy/paste this json text to any text editor; 5.1.5. Find the "limit":100 parameter and change it to some big value, e.g. 250000. Save the file.

  1. use the download method to download the data: my_rfgfLoader.download('<>', '<>')

  2. use the attached d_r.gpkg geopackage ar create an empty geopackage with multipolygon layer l_b (you can use QGIS) with WGS-1984 GCS and the following attribute structure:

field_name Type Length

gos_reg_num String 0 date_register Date 0 license_purpose String 0 resource_type String 0 license_block_name String 0 region String 0 status String 0 user_info String 0 licensor String 0 license_doc_requisites String 0 license_cancel_order_info String 0 date_stop_subsoil_usage Date 0 limit_conditions_stop_subsoil_usage String 0 date_license_stop Date 0 previous_license_info String 0 asln_link String 0 source String 0 license_update_info String 0 license_re_registration_info String 0 rfgf_link String 0 comments String 0 source_gcs String 0 coords_text String 0

  1. use the json2gpkg method to convert downloaded json data file to geopackage:

my_rfgfLoader.json2gpkg('path to json data file', 'path to geopackage', 'layer name')

And don't forget to read the functions' infotext!

About

Python script to download data from https://rfgf.ru/ReestrLic/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages