官术网_书友最值得收藏!

Preparing our data

From the currently opened vector layers, the GeoNames layer has the largest attribute table with the most kinds of attributes. However, as the extract does not contain headers, it is quite hard to work with it. Fortunately, CSV files can be edited as regular text files or as spreadsheets. As the first step, let's open the GeoNames file with a text editor and prepend a header line to it. It is tab delimited; therefore, we need to separate the field names with tabs. The field names can be read out from the readme file in order. In the end, we should have a first line looking something like this:

    geonameid name asciiname alternatenames latitude longitude
featureclass
featurecode countrycode cc2 admin1 admin2 admin3 admin4 population
elevation
dem timezone modification
If you use a text or code editor which replaces tabs with spaces, don't forget to switch off that feature before adding the header line. Furthermore, copy-pasting the preceding code block will probably not work.

Now we can remove our GeoNames layer from the layer tree and add it again. In the form, we have to check the option First record has field names. If we do so, and name the latitude and longitude fields accordingly, we can see QGIS automatically filling the X and Y fields:

You can speed up rendering and spatial querying by checking  Use spatial index. It will consume some memory though, so be careful with unusually large files. If you have such a big GeoNames layer that you cannot work with (like the whole U.S. table on a weaker computer), you can choose another layer for the next part.
主站蜘蛛池模板: 湘阴县| 松阳县| 衡南县| 千阳县| 桐柏县| 兖州市| 中江县| 蕲春县| 海林市| 宝丰县| 澜沧| 昭觉县| 卢氏县| 龙泉市| 芦山县| 嘉善县| 江陵县| 贡嘎县| 克什克腾旗| 岳阳县| 和静县| 深泽县| 新巴尔虎右旗| 布拖县| 衡南县| 泸州市| 大理市| 盐津县| 新津县| 栖霞市| 河池市| 木里| 临湘市| 扶余县| 塔城市| 上饶市| 南汇区| 元氏县| 五莲县| 阜城县| 张掖市|