1

Or do I need to rewrite my script using "pure Python" and PyQGIS? My script is basically a recreation of ArcMap's Tabulate Area tool (vector layers only for now). The goal is to make it official in the QGIS plugin repository

Code snippet

data = [] 
for a in range(gdf1.shape[0]):
    muni = gdf1.loc[gdf1['NAME_2'] == gdf1['NAME_2'][a]] 
    intersection = gpd.overlay(muni, gdf2, how='intersection') 
    area = intersection['geometry'].map(lambda p: p.area) 
    type_in = intersection['DESCRIPT'].values.tolist() 
    type_all = gdf2['DESCRIPT'].values.tolist() 
     
    ...

df3 = pd.DataFrame(data, columns = cols) # creates df
df3.insert(0, 'zones', rows) # creates df's rows
df3.to_csv('munis_landCover_tabulated.csv')
  • 1
    Please only use the Title area for a summary of what is in your question body. Your question body should stand alone. – PolyGeo Jun 20 '20 at 7:51
3

The QGIS plugin repository does not require you to exclude external dependencies. In fact there are several plugins that use third-party Python modules.

But, and please consider this a significant but, this makes your plugin hard to use, if not almost impossible to install for many users. Installing Python modules to the right environment so that QGIS picks them up is not trivial. Installing the correct versions is not trivial. Even "just" installing any Python modules is not trivial.

I would highly recommend that you rewrite your code to use pure Python and PyQGIS so that it works out of the box. Your potential users will thank you.

  • 1
    Yes. I realized that too. Even I had a hard time installing GeoPandas with its massive dependencies. If anyone is going to read this, writing a plugin from scratch with Python and PyQGIS is hard for any beginner so I just made a model and exported it as a python script. From there, it's just a matter of adding functionality. Thanks, @bugmenot123! – BallpenMan Jun 20 '20 at 14:02
  • 1
    Although it is easy to use pyqgis to write plugins it is not uncommon to use another python module. Since QGIS 3.8 there is an option qgis.org/en/site/forusers/visualchangelog38/index.html#plugins. This allows you to specify what external dependency your plugin requires. This will just limit the audience for your plugin because you would expect the users to know how to install the extra dependencies in this case geopandas – kartoza-geek Jun 20 '20 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.