1

I have a large shapefile of lines, and want to run a mmqgis function (Plugins --> mmqgis --> Modify --> Convert Geometry Type.)

The problem is the file is very large and crashes the program. What options do I have?

Would running it as background python script work (and if so how do I find the commands for mmqgis function?)?

There are 460'000 features and i'm running a 3.40GHz i7 with 12GB of RAM. Is there a way of this not breaking down?

3
  • Can you give us your system specs, and how many features are in your .shp?
    – HDunn
    Commented Jun 6, 2013 at 8:46
  • There are 460'000 features and i'm running a 3.40GHz i7 with 12GB of RAM.
    – DGraham
    Commented Jun 6, 2013 at 9:42
  • Woops missed the mention @HDunn
    – DGraham
    Commented Jun 6, 2013 at 10:29

4 Answers 4

4

You might try importing the shp into postgis with shp2pgsql and running the query for ST_Centroid in the database. See the docs here.

2
  • PostGIS is excellent tool for "big" data needs for normal users (i know 460k lines isn't big data) Commented Jun 6, 2013 at 17:33
  • Sptailite might be a better option.
    – Nathan W
    Commented Jun 6, 2013 at 21:06
2

To calculate the coordinates of each line segment's midpoint, create two new fields using the functions:

(x_max( $geometry ) + x_min( $geometry ))/2

and

(y_max( $geometry ) + y_min( $geometry ))/2
0

With FME Desktop, you can use this transformer: CenterOfGravityReplacer. It's very easy to use this.

Replaces the geometry of the feature with a point at the center of mass of the feature. Note that, depending on the feature’s shape, the resulting point may be far outside of the original feature.

Example The transformer calculates the exact distribution of portions of a shape; therefore, some points can actually appear outside a feature.

3
  • 1
    FME is nice tools, but commercial and costs about 2k€ + annual support fee Commented Jun 6, 2013 at 17:30
  • 1
    I don't know why this question received a downvote. FME is a completely valid answer to this question. The OP doesn't specify free software as a requirement. It may be valid for other users in the future. I would upvote it, but I've reached my daily vote limit.
    – Fezter
    Commented Jun 7, 2013 at 1:15
  • Upvote. Yes i hate it now and then , but it solves a lot more problems than it causes. It's excellent tool to file conversion and it can also manipulate data. Only minus comes from fact that it is commercial with annoying license handling. For last two years i have "wasted" several days when waiting license keys to arrive. Also it probably saves license stuff in to primary hd boot sector because i wasted 2 days after i had move my all data to bigger ssd hd. Windows and all other programs didn't even need re-activation. Commented Jun 7, 2013 at 7:15
0

If you don't want to set up a database like zimmi suggested I would use GDAL/OGR with the Centroid function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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