Is it possible to work with shp files in Delphi?

Asked

Viewed 461 times

8

I would like to assemble an application that would have the function of a GIS (QGIS for example), that instead of developing a plugin that depends on it from the software to work, generate in Delphi an independent executable.

I already own a script similar ugly in R and Python. The Qgis opens the outline of the map, and the person opens the script and generate some points based on a geostatistical calculation.

So at first the initial functions should be something like reading the file shp polygonised and display on the screen, and from there generate the points taking into account the conditions of the map.

I think that would depend on some library, I couldn’t find example, do they exist? Is it possible?

  • only a doubt . shp is the format Shapefile Shape or Autocad?

  • the . shp format that can be done in auto Cad, gps and other...

  • 4

    To begin, and I am interested in helping you rsrsrsrs,edit the question and post a part of the file, and if possible inform what you want with this data, whether it will save in database, etc., If I do not find something to adapt to you, we will develop from Zero a solution, of course the information I asked for is crucial to such an approach!

  • Okay, I’ll rephrase the question.

1 answer

6


Friend, the research was great and I got great results!

Today there are already solutions for this, so I analyzed several and several and I ended up finding several solutions, however, you will need a greater effort to reach the level you want!

Currently the files are not summarized only in .SHP, updated today:

SHP: The graphical data
SHX: The index
DBF: Attribute data

The easiest solution today is the library Shapelib (ShpAPI129.pas & shapelib.dll).

Functional for the Delphi 7, you will find some problem in some of its functions, mainly at the time of opening the files, but I will already pass the tip!

I’m not sure which version of Delphi has since been modified, but I assure you that Delphi 2009 from the Default is Unicode characters, therefore, in the call functions of the library you need to change:

Function SHPOpen (pszShapeFile: PChar; pszAccess: PChar): SHPHandle; cdecl; external LibName name '_SHPOpen';

//para:

Function SHPOpen (pszShapeFile: PAnsiChar; pszAccess: PAnsiChar): SHPHandle; cdecl; external LibName name '_SHPOpen';


//observe a mudança do PChar para PAnsiChar

If you do not make the above mentioned change, the return of the function will be nil. In the version Delphi 7 works without the conversion!

Here a project is stopped, but several tools and examples are still available: Cartovcl

In English, but super useful to increase knowledge: Delphi Gis Wiki

Abandoned topic from a forum on the subject: Pointinshapefile and Shape Fill with Delphi

  • Very nice, it was the information I need to start working, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.