This project has moved and is read-only. For the latest updates, please go here.

Reduce labels in layer

Sep 30, 2011 at 7:00 AM
Edited Sep 30, 2011 at 7:09 AM

SharpMap 0.9 ASP.NET control

I have this  US Cities ShapeFile  with 40k cities. As you can image, this is way too many to display.

1. Can I load the labels selectively, based on some criteria like population > some no.?

2. Is there any way I can remove some of the cities? What tool do I use?

Sep 30, 2011 at 8:15 AM
Edited Sep 30, 2011 at 8:16 AM

1.) You need to enable CollistionDetection and set either

  • the PriorityColumn to a numerical column or
  • the PriorityDelegate function (see code comments for example).

2.) Depending on the datasource you use, you could either

  • create views (DataBase) and pass their name as table name
  • use ogr2ogr (File based datasource, e.g. ShapeFile) to sort out unwanted labels

Hth FObermaier

Oct 1, 2011 at 10:13 AM

1. I have CollisionDetection enabled with Priority Column. But that does not help my situation as that helps only collision not filtering out data.

2. I used ogr2ogr to reduce some unwanted columns and records. from the ShapeFile

 I am using the new ShapeFile for the label layer. It still has 35k data. I do not want to reduce it further.

I need to have some method to keep this ShapeFile intact, but setup a column with a Y/N and load/display only those labels that have a Y.
This way the customer can keep adding & deleting the cities as the need arises.

When you said

<QUOTE> create views (DataBase) and pass their name as table name </QUOTE>

Do you mean port the shapefile to SQL database & set a filter there & load only required labels?

If so, what is a good tool to convert the ShapeFile to SQL?

Oct 1, 2011 at 7:54 PM

If database is an option for you, you should first consider which one to choose.

Since your source data is in Shapefile format, I cannot imagine that there isn't an import utility, since shapefile format is the defaco standard gis exchange format.
If you can't find one, use ogr2ogr, it handles almost all formats.

Hth FObermaier