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

[ENH] Open MPK files in Python/GemGIS #298

Closed
AlexanderJuestel opened this issue Aug 19, 2023 · 1 comment
Closed

[ENH] Open MPK files in Python/GemGIS #298

AlexanderJuestel opened this issue Aug 19, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request functionality Introducing new functionality

Comments

@AlexanderJuestel
Copy link
Collaborator

AlexanderJuestel commented Aug 19, 2023

Is your feature request related to a problem? Please describe.
GemGIS should be capable of reading MPK files.

See: https://docs.fileformat.com/gis/mpk/#:~:text=Create%20MPK%20File%20Using%20ArcGIS,-MPK%20files%20can&text=The%20%E2%80%9CShare%20As%E2%80%9D%20option%20in,view%20the%20map%20and%20data.

Describe the solution you'd like

  • Using os.rename() to rename .mpk to .zip
import os
file_in = 'file.mpk'
file_out = file_in.split('.mpk')[0]
os.rename(file_in, file_out+'.zip')
  • Using ´py7zrandarchive.extractall()` to extract all files
import py7zr
with py7zr.SevenZipFile(file_out+'.zip', 'r') as archive:
    archive.extractall(path=file_out)
  • Using os.walk() to go through all directories and list all shapefiles
files = [os.path.join(path, name) for path, subdirs, files in os.walk(file_out) for name in files if name.endswith(".shp")]
  • Open shapefiles using GeoPandas and return them as dict with the file names as keys
gdfs = {file.rsplit('\\')[-1]: gpd.read_file(file) for file in files}

Describe alternatives you've considered
Renaming the file manually and open the shapefiles manually

Additional context
No other package was found so far that can do this

@AlexanderJuestel AlexanderJuestel self-assigned this Aug 19, 2023
@AlexanderJuestel AlexanderJuestel added enhancement New feature or request functionality Introducing new functionality labels Aug 19, 2023
@AlexanderJuestel AlexanderJuestel added this to the GemGIS 1.2 milestone Aug 19, 2023
@AlexanderJuestel AlexanderJuestel mentioned this issue Aug 21, 2023
6 tasks
@AlexanderJuestel AlexanderJuestel changed the title Open MPK files in Python/GemGIS [ENH] Open MPK files in Python/GemGIS Sep 5, 2023
@AlexanderJuestel
Copy link
Collaborator Author

Added in #299

@AlexanderJuestel AlexanderJuestel removed this from the GemGIS 1.2 milestone Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request functionality Introducing new functionality
Projects
None yet
Development

No branches or pull requests

1 participant