Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: A command to load shape files from a given directory #11

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

DavidTheProgrammer
Copy link

@DavidTheProgrammer DavidTheProgrammer commented Nov 25, 2024

Description

This command loads shape files that match a glob pattern into the database using the loadshp command internally. It takes a list of arguments that provide possible sources for key variables for the loadshp command like the level and field_map.

Why?

This command simplifies the processes of loading multiple shape files into the backend rather than calling the loadshp command for each file individiually.

Related Issue

#7

How to test it locally

Have a directory of shape files ready to load and specify them in the command with appropriate keys for possible fields in the shape files to find specific information. e.g:

python manage.py loadshpfiles ./datasets/shapefiles/country-regions/\*/output/\*.shp code Name,NAME parent_cod,ptr_cd area ENGTYPE_1,Region,REGION Africa Climate

The command above provides the following arguments:

  • pattern matching shapefiles to load.
  • possible fields to obtain the code from.
  • possible fields to obtain the name from.
  • possible fields to obtain the parent_code from.
  • possible fields to obtain the area from.
  • possible fields to obtain the level from.
  • The hierarchy the files are part of.
  • The geography version.

These are all arguments the loadshp command needs to load a shape file.

Checklist

  • 🚀 is the code ready to be merged and go live?
  • 🛠 does it work (build) locally

Pull Request

  • 📰 good title
  • 📝good description
  • 🔖 issue linked
  • 📖 changelog filled out

Commits

  • commits are clean
  • commit messages are clean

Code Quality

  • 🚧 no commented out code
  • 🖨 no unnecessary logging
  • 🎱 no magic numbers
  • black was run locally (as part of the pre-commit hook)

Testing

  • ✅ added (appropriate) unit tests
  • 💢 edge cases in tests were considered
  • ✅ ran tests locally & are passing

@DavidTheProgrammer DavidTheProgrammer changed the title A command to load shp files from a given directory Feature: A command to load shp files from a given directory Nov 25, 2024
@DavidTheProgrammer DavidTheProgrammer changed the title Feature: A command to load shp files from a given directory Feature: A command to load shape files from a given directory Nov 25, 2024
@DavidTheProgrammer DavidTheProgrammer marked this pull request as ready for review November 25, 2024 14:25
@DavidTheProgrammer DavidTheProgrammer requested a review from a team November 26, 2024 07:31
@kilemensi
Copy link
Member

@DavidTheProgrammer, is this any different from something along the lines: find . -name '*.sph' -exec ./manage.py loadshp {} <other args>\; i.e. for each file matching glob/pattern, call loadshp with the filename + other args?

@DavidTheProgrammer
Copy link
Author

@DavidTheProgrammer, is this any different from something along the lines: find . -name '*.sph' -exec ./manage.py loadshp {} <other args>\; i.e. for each file matching glob/pattern, call loadshp with the filename + other args?

Hi @kilemensi, yes, It's different. Each shape file has different fields to find the necessary values to use, so this command uses the provided list to find the first matching field in each shapefile and use that as an argument. If we used the find command, some files wouldn't load because the provided fields would not be found.

@DavidTheProgrammer DavidTheProgrammer self-assigned this Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 Icebox
Development

Successfully merging this pull request may close these issues.

2 participants